package chapter04.sync;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.LockSupport;

// 两个线程必须先打印2再打印1
@Slf4j
public class TwoOneTest2 {
    static boolean flag=false;
    public static void main(String[] args) throws InterruptedException {

        Thread t1 = new Thread(() -> {
            LockSupport.park();
            log.debug("{}",1);
        }, "t1");

        Thread t2 = new Thread(() -> {

            log.debug("{}",2);
            LockSupport.unpark(t1);
        }, "t2");
        t1.start();
        t2.start();

    }
}
